Fix stdlib defines for AArch32
authorSoby Mathew <[email protected]>
Tue, 6 Jun 2017 09:01:03 +0000 (10:01 +0100)
committerSoby Mathew <[email protected]>
Fri, 9 Jun 2017 13:47:52 +0000 (14:47 +0100)
Some of the macro defines in the header files of `include/lib/stdlib/machine/`
folder are not correct for AArch32. This patch fixes the same.

Change-Id: I8bfaf638a7986fd902648d2074537bd26c313cb3
Signed-off-by: Soby Mathew <[email protected]>
include/lib/stdlib/machine/_limits.h
include/lib/stdlib/machine/_stdint.h

index 49a768b087e085afad95588413bd12cc527bf848..3bdc66f14595b2155cfa7ea909da5b2f1f88dbdc 100644 (file)
  * $FreeBSD$
  */
 
+/*
+ * Portions copyright (c) 2017, ARM Limited and Contributors.
+ * All rights reserved.
+ */
+
 #ifndef        _MACHINE__LIMITS_H_
 #define        _MACHINE__LIMITS_H_
 
 #define        __SHRT_MAX      0x7fff          /* max value for a short */
 #define        __SHRT_MIN      (-0x7fff-1)     /* min value for a short */
 
-#define        __UINT_MAX      0xffffffff      /* max value for an unsigned int */
+#define        __UINT_MAX      0xffffffffU     /* max value for an unsigned int */
 #define        __INT_MAX       0x7fffffff      /* max value for an int */
 #define        __INT_MIN       (-0x7fffffff-1) /* min value for an int */
 
-#define        __ULONG_MAX     0xffffffffffffffff      /* max for an unsigned long */
-#define        __LONG_MAX      0x7fffffffffffffff      /* max for a long */
-#define        __LONG_MIN      (-0x7fffffffffffffff-1) /* min for a long */
-
-/* Long longs have the same size but not the same type as longs. */
-                                       /* max for an unsigned long long */
-#define        __ULLONG_MAX    0xffffffffffffffffULL
+#ifdef AARCH32
+#define        __ULONG_MAX     0xffffffffUL    /* max for an unsigned long */
+#define        __LONG_MAX      0x7fffffffL     /* max for a long */
+#define        __LONG_MIN      (-0x7fffffffL-1) /* min for a long */
+#else
+#define        __ULONG_MAX     0xffffffffffffffffUL    /* max for an unsigned long */
+#define        __LONG_MAX      0x7fffffffffffffffL     /* max for a long */
+#define        __LONG_MIN      (-0x7fffffffffffffffL-1) /* min for a long */
+#endif
+
+#define        __ULLONG_MAX    0xffffffffffffffffULL   /* max for an unsigned long long */
 #define        __LLONG_MAX     0x7fffffffffffffffLL    /* max for a long long */
 #define        __LLONG_MIN     (-0x7fffffffffffffffLL-1) /* min for a long long */
 
 #define        __OFF_MAX       __LONG_MAX      /* max value for an off_t */
 #define        __OFF_MIN       __LONG_MIN      /* min value for an off_t */
 
+#ifdef AARCH32
+/* Quads and long longs are the same size.  Ensure they stay in sync. */
+#define        __UQUAD_MAX     (__ULLONG_MAX)  /* max value for a uquad_t */
+#define        __QUAD_MAX      (__LLONG_MAX)   /* max value for a quad_t */
+#define        __QUAD_MIN      (__LLONG_MIN)   /* min value for a quad_t */
+#else
 /* Quads and longs are the same size.  Ensure they stay in sync. */
 #define        __UQUAD_MAX     (__ULONG_MAX)   /* max value for a uquad_t */
 #define        __QUAD_MAX      (__LONG_MAX)    /* max value for a quad_t */
 #define        __QUAD_MIN      (__LONG_MIN)    /* min value for a quad_t */
+#endif
 
+#ifdef AARCH32
+#define        __LONG_BIT      32
+#else
 #define        __LONG_BIT      64
+#endif
 #define        __WORD_BIT      32
 
 /* Minimum signal stack size. */
index 9a4f35fdb4facc2e69ffbbc21726686d218a35fe..ee5372d541f6387ddd4d525c17639d5a6270a865 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 /*
- * Portions copyright (c) 2016, ARM Limited and Contributors.
+ * Portions copyright (c) 2016-2017, ARM Limited and Contributors.
  * All rights reserved.
  */
 
  * ISO/IEC 9899:1999
  * 7.18.2.4  Limits of integer types capable of holding object pointers
  */
+#ifdef AARCH32
+#define        INTPTR_MIN      INT32_MIN
+#define        INTPTR_MAX      INT32_MAX
+#define        UINTPTR_MAX     UINT32_MAX
+#else
 #define        INTPTR_MIN      INT64_MIN
 #define        INTPTR_MAX      INT64_MAX
 #define        UINTPTR_MAX     UINT64_MAX
+#endif
 
 /*
  * ISO/IEC 9899:1999
  * 7.18.3  Limits of other integer types
  */
 /* Limits of ptrdiff_t. */
-#define        PTRDIFF_MIN     INT64_MIN       
+#ifdef AARCH32
+#define        PTRDIFF_MIN     INT32_MIN
+#define        PTRDIFF_MAX     INT32_MAX
+#else
+#define        PTRDIFF_MIN     INT64_MIN
 #define        PTRDIFF_MAX     INT64_MAX
+#endif
 
 /* Limits of sig_atomic_t. */
 #define        SIG_ATOMIC_MIN  INT32_MIN
 #define        SIG_ATOMIC_MAX  INT32_MAX
 
 /* Limit of size_t. */
+#ifdef AARCH32
+#define        SIZE_MAX        UINT32_MAX
+#else
 #define        SIZE_MAX        UINT64_MAX
+#endif
 
 #ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */
 /* Limits of wchar_t. */